<template>
    <view class="container" v-if="order.uuid">
        <view class="address-c padding" v-if="address && address.consignee">
            <view class="al-icon-coordinates"></view>
            <view class="body">
                <view class="name">
                    <text>{{ address.consignee }}</text>
                    <text style="padding-left: 16rpx">{{ address.phone }}</text>
                </view>
                <view class="detail">
                    <text>{{ address.province + ' ' + address.city + ' ' + address.district + ' ' + address.address }}</text>
                </view>
            </view>
        </view>
        <view class="products-c">
            <sku-item @__l="__l" class="sku" :info="item" :vueId="'abcae766-1-' + index" v-for="(item, index) in skus" :key="index"></sku-item>
        </view>
        <view class="price-wrap padding-h">
            <view class="list-item">
                <view class="body">商品总价</view>
                <view class="arrow-right">
                    <price-display @__l="__l" :info="order" prefix="product_" vueId="abcae766-2"></price-display>
                </view>
            </view>
            <view class="list-item" v-if="order.exchange_record_id">
                <view class="body">置换抵扣</view>
                <view class="arrow-right">
                    -
                    <price-display @__l="__l" :info="order" moneyKey="exchange_money_discount" scoreKey="exchange_score_discount" vueId="abcae766-3"></price-display>
                </view>
            </view>
            <view class="list-item" v-if="order.cover_type">
                <view class="body">兑换类型</view>
                <view class="arrow-right">
                    <text class="meta" v-if="order.cover_type === 'chip'">碎片兑换</text>
                    <block v-else>
                        <text class="meta" v-if="order.cover_type === 'score'">{{ scoreAlias + '兑换' }}</text>
                    </block>
                </view>
            </view>
            <view class="list-item" v-if="order.cover_discount">
                <view class="body">兑换抵扣</view>
                <view class="arrow-right">{{ '-¥' + $root.f0 + '' }}</view>
            </view>
            <view class="list-item">
                <view class="body">优惠券</view>
                <view class="arrow-right" style="color: #ff5700">{{ '-¥' + $root.f1 + '' }}</view>
            </view>
            <view class="list-item">
                <view class="body">红包</view>
                <view class="arrow-right">{{ '-¥' + $root.f2 + '' }}</view>
            </view>
            <view class="list-item" v-if="order.score_discount">
                <view class="body">{{ '' + scoreAlias + '抵扣' }}</view>
                <view class="arrow-right">{{ '' + order.score_used + scoreAlias + '   -¥' + $root.f3 + '' }}</view>
            </view>
            <view class="list-item">
                <view class="body">运费</view>
                <view class="arrow-right" v-if="order.carriage_type === 2">到付</view>
                <view class="arrow-right" v-else>{{ '+¥' + $root.f4 + '' }}</view>
            </view>
            <view class="total-price border-top">
                <view style="padding-left: 14rpx">
                    <text class="key">实付:</text>
                    <view class="price-c">
                        <price-display @__l="__l" :info="order" prefix="pay_" vueId="abcae766-4"></price-display>
                    </view>
                </view>
            </view>
        </view>
        <view class="meta-c padding-h">
            <view class="list-item">
                <view class="body">订单编号</view>
                <view class="arrow-right">
                    {{ '' + order.number + '' }}
                    <text @tap="__e" class="fuzhi" :data-event-opts="[['tap', [['setCopyText', ['$0'], ['order.number']]]]]">复制</text>
                </view>
            </view>
            <view class="list-item" v-if="order.created_at">
                <view class="body">下单时间</view>
                <view class="arrow-right">{{ '' + order.created_at + '' }}</view>
            </view>
            <view class="list-item" v-if="order.paid_at">
                <view class="body">支付时间</view>
                <view class="arrow-right">{{ '' + order.paid_at + '' }}</view>
            </view>
            <view class="list-item">
                <view class="body">订单状态</view>
                <view class="arrow-right status-text">{{ '' + order.union_status_text + '' }}</view>
            </view>
            <block v-if="deliverRecord">
                <view class="list-item" v-if="deliverRecord.express_name">
                    <view class="body">快递公司</view>
                    <view class="arrow-right">{{ '' + deliverRecord.express_name + '' }}</view>
                </view>
                <view class="list-item" v-if="deliverRecord.express_number">
                    <view class="body">快递单号</view>
                    <view class="arrow-right">
                        {{ '' + deliverRecord.express_number + '' }}
                        <text @tap="__e" :data-event-opts="[['tap', [['setCopyText', ['$0'], ['deliverRecord.express_number']]]]]" style="color: #1890ff; margin-left: 10rpx">
                            复制
                        </text>
                    </view>
                </view>
                <view class="list-item" v-if="deliverRecord.remark">
                    <view class="body">发货备注</view>
                    <view class="arrow-right">{{ '' + deliverRecord.remark + '' }}</view>
                </view>
            </block>
        </view>
        <view style="height: 150rpx"></view>
        <view class="footer-actions safe-area-bottom">
            <button @tap="__e" class="action-item no-border-button" :data-event-opts="[['tap', [['openContact', ['$event']]]]]" openType="contact">
                <image class="action-item-img" src="https://img121.7dun.com/yuanqimali/orderDetail/kefu.png"></image>
                <text>客服</text>
            </button>
            <navigator
                class="action-item"
                hoverClass="hover"
                :url="'/pages/orderCode/index?uuid=' + order.uuid"
                v-if="order.union_status == 'deliver_pending' && order.is_offline_useable"
            >
                <view class="icon new-iconfont icon-qrcode"></view>
                <text>核销码</text>
            </navigator>
            <view style="flex-grow: 1"></view>
            <block v-if="order.union_status == 'pay_pending'">
                <view @tap="__e" class="btn" :data-event-opts="[['tap', [['visibleChange', ['$event']]]]]" v-if="order.is_closeable">
                    <text>取消订单</text>
                </view>
                <view @tap="__e" class="btn bg-oranges" :data-event-opts="[['tap', [['payNow', ['$event']]]]]">
                    <text>立即支付</text>
                </view>
            </block>
            <view class="btn bg-oranges" v-if="order.union_status == 'deliver_pending'">
                <text>等待发货</text>
            </view>
            <view class="btn" v-if="order.union_status == 'delivered'">
                <text>已发货</text>
            </view>
            <view class="btn bg-oranges" v-if="order.union_status == 'return_sale'">
                <text>已返售退款</text>
            </view>
            <view class="btn bg-oranges" v-if="order.union_status == 'covered'">
                <text>已兑换成碎片</text>
            </view>
            <block v-if="order.union_status == 'pending'">
                <view @tap="__e" class="btn bg-oranges" :data-event-opts="[['tap', [['returnSale', ['$event']]]]]" v-if="!orderConfig.is_ban_return_sale">
                    <text>返售</text>
                </view>
                <view @tap="__e" class="btn bg-oranges" :data-event-opts="[['tap', [['selectDeliver', ['$event']]]]]" v-if="!orderConfig.is_hide_deliver_btn">
                    <text>选择发货</text>
                </view>
            </block>
            <view @tap="__e" class="btn" :data-event-opts="[['tap', [['destoryOrder', ['$event']]]]]" v-if="order.union_status == 'closed'">
                <text>删除订单</text>
            </view>
            <block v-if="order.union_status == 'close_pending'">
                <button class="btn bg-oranges" openType="contact" v-if="isMiniappAndUseMiniappKf">
                    <text>联系客服</text>
                </button>
                <button @tap="__e" class="btn bg-oranges" :data-event-opts="[['tap', [['openContact', ['$event']]]]]" v-else>
                    <text>联系客服</text>
                </button>
            </block>
        </view>
        <i-action-sheet
            @__l="
                __l($event, {
                    eventOpts: [
                        ['^visibleChange', [['visibleChange']]],
                        ['^change', [['cancelOrder']]]
                    ]
                })
            "
            @change="
                __e($event, {
                    eventOpts: [
                        ['^visibleChange', [['visibleChange']]],
                        ['^change', [['cancelOrder']]]
                    ]
                })
            "
            @visibleChange="
                __e($event, {
                    eventOpts: [
                        ['^visibleChange', [['visibleChange']]],
                        ['^change', [['cancelOrder']]]
                    ]
                })
            "
            :data-event-opts="[
                ['^visibleChange', [['visibleChange']]],
                ['^change', [['cancelOrder']]]
            ]"
            :list="reasons"
            title="选择理由"
            :visible="visible"
            vueId="abcae766-5"
        ></i-action-sheet>
        <return-sale-popup
            @__l="
                __l($event, {
                    eventOpts: [
                        ['^cancel', [['e0']]],
                        ['^refresh', [['getOrderInfo']]]
                    ]
                })
            "
            @cancel="
                __e($event, {
                    eventOpts: [
                        ['^cancel', [['e0']]],
                        ['^refresh', [['getOrderInfo']]]
                    ]
                })
            "
            @refresh="
                __e($event, {
                    eventOpts: [
                        ['^cancel', [['e0']]],
                        ['^refresh', [['getOrderInfo']]]
                    ]
                })
            "
            :data-event-opts="[
                ['^cancel', [['e0']]],
                ['^refresh', [['getOrderInfo']]]
            ]"
            :uuid="uuid"
            vueId="abcae766-6"
            v-if="isShowReturnSalePopup"
        ></return-sale-popup>
    </view>
</template>

<script>
import skuItem from '@/components/SkuItem/SkuItem';
import priceDisplay from '@/components/PriceDisplay/PriceDisplay';
import returnSalePopup from '@/components/ReturnSalePopup/ReturnSalePopup';
import iActionSheet from '@/components/ActionSheet/index';
import tabBar from '@/components/TabBar/tabBar';
(global.webpackJsonp = global.webpackJsonp || []).push([
    ['pages/orderDetail/index'],
    {
        '037a': function (e, n, t) {},
        '2f81': function (e, n, t) {
            'use strict';

            t.r(n);
            var i = t('498b');
            var o = t('7782');
            for (var r in o) {
                if (['default'].indexOf(r) < 0) {
                    (function (e) {
                        t.d(n, e, function () {
                            return o[e];
                        });
                    })(r);
                }
            }
            t('d37e');
            var u = t('f0c5');
            var d = Object(u.a)(o.default, i.b, i.c, false, null, null, null, false, i.a, void 0);
            n.default = d.exports;
        },
        '498b': function (e, n, t) {
            'use strict';

            t.d(n, 'b', function () {
                return o;
            });
            t.d(n, 'c', function () {
                return r;
            });
            t.d(n, 'a', function () {
                return i;
            });
            var i = {
                SkuItem: function () {
                    return Promise.all([t.e('common/vendor'), t.e('components/SkuItem/SkuItem')]).then(t.bind(null, '3c3e'));
                },
                PriceDisplay: function () {
                    return t.e('components/PriceDisplay/PriceDisplay').then(t.bind(null, '6b05'));
                },
                ReturnSalePopup: function () {
                    return t.e('components/ReturnSalePopup/ReturnSalePopup').then(t.bind(null, 'f4ef'));
                }
            };
            var o = function () {
                var that = this;
                var n = (that.$createElement, that._self._c, that.order.uuid && that.order.cover_discount ? that._f('priceToFixed')(that.order.cover_discount) : null);
                if (that.order.uuid) {
                    var t = that._f('priceToFixed')(that.order.coupon_discount);
                } else {
                    var t = null;
                }
                if (that.order.uuid) {
                    var i = that._f('priceToFixed')(that.order.redpack_discount);
                } else {
                    var i = null;
                }
                var o = that.order.uuid && that.order.score_discount ? that._f('priceToFixed')(that.order.score_discount) : null;
                var r = that.order.uuid && 2 !== that.order.carriage_type ? that._f('priceToFixed')(that.order.carriage) : null;
                that._isMounted ||
                    (that.e0 = function (n) {
                        that.isShowReturnSalePopup = false;
                    });
                that.$mp.data = Object.assign(
                    {},
                    {
                        $root: {
                            f0: n,
                            f1: t,
                            f2: i,
                            f3: o,
                            f4: r
                        }
                    }
                );
            };
            var r = [];
        },
        7782: function (e, n, t) {
            'use strict';

            t.r(n);
            var i = t('af51');
            var o = t.n(i);
            for (var r in i) {
                if (['default'].indexOf(r) < 0) {
                    (function (e) {
                        t.d(n, e, function () {
                            return i[e];
                        });
                    })(r);
                }
            }
            n.default = o.a;
        },
        af51: function (e, n, t) {
            'use strict';

            (function (e) {
                var i = t('4ea4');
                Object.defineProperty(n, '__esModule', {
                    value: true
                });
                n.default = void 0;
                var o = {
                    mixins: [i(t('452d')).default],
                    components: {
                        IActionSheet: function () {
                            t.e('components/ActionSheet/index')
                                .then(
                                    function () {
                                        return resolve(t('fbfb'));
                                    }.bind(null, t)
                                )
                                .catch(t.oe);
                        }
                    },
                    data: function () {
                        return {
                            deliverRecord: null,
                            visible: false,
                            reasons: [],
                            address: {},
                            order: {},
                            skus: [],
                            uuid: '',
                            isShowReturnSalePopup: false
                        };
                    },
                    filters: {
                        hidePhoneDetail: function (e) {
                            return e ? e.substring(0, 3) + '****' + e.substring(7, 11) : '';
                        }
                    },
                    computed: {
                        orderConfig: function () {
                            return this.$store.getters.setting.order;
                        }
                    },
                    onLoad: function (e) {
                        var that = this;
                        this.uuid = e.uuid;
                        this.$api.emit('order.cancel_reason.list').then(function (e) {
                            that.reasons = e.data.list;
                        });
                    },
                    onShow: function () {
                        this.getOrderInfo();
                    },
                    methods: {
                        selectDeliver: function () {
                            e.navigateTo({
                                url: '/pages/orderList/index'
                            });
                        },
                        returnSale: function () {
                            this.isShowReturnSalePopup = true;
                        },
                        setCopyText: function (n) {
                            e.setClipboardData({
                                data: n,
                                success: function (n) {
                                    e.showToast({
                                        title: '复制成功'
                                    });
                                }
                            });
                        },
                        getOrderInfo: function () {
                            var that = this;
                            var t = this.uuid;
                            e.showLoading({
                                title: '加载中',
                                mask: true
                            });
                            this.$api.emit('order.show', t).then(function (t) {
                                e.hideLoading();
                                that.order = t.data.info;
                                that.address = t.data.info.address;
                                that.skus = t.data.info.skus;
                                that.deliverRecord = t.data.info.deliver_record;
                            });
                        },
                        visibleChange: function () {
                            this.visible = !this.visible;
                        },
                        payNow: function () {
                            e.navigateTo({
                                url: '/pages/payCenter/index?uuid=' + this.order.uuid
                            });
                        },
                        cancelOrder: function (n) {
                            var that = this;
                            this.visibleChange();
                            e.showLoading({
                                title: '加载中',
                                mask: true
                            });
                            this.$api
                                .emit('order.close', this.order.uuid)
                                .then(function (n) {
                                    e.hideLoading();
                                    e.showToast({
                                        title: '订单已取消',
                                        icon: 'none'
                                    });
                                    that.order.union_status = 'closed';
                                })
                                .catch(function (n) {
                                    e.hideLoading();
                                });
                        },
                        destoryOrder: function (n) {
                            e.showLoading({
                                title: '加载中',
                                mask: true
                            });
                            this.$api
                                .emit('order.destory', this.order.uuid)
                                .then(function (n) {
                                    e.hideLoading();
                                    e.showToast({
                                        title: '订单已删除',
                                        icon: 'none'
                                    });
                                    setTimeout(function (n) {
                                        e.navigateBack({
                                            delta: 1
                                        });
                                    }, 1000);
                                })
                                .catch(function (n) {
                                    e.hideLoading();
                                });
                        }
                    }
                };
                n.default = o;
            }.call(this, t('543d').default));
        },
        cc2b: function (e, n, t) {
            'use strict';

            (function (e, n) {
                var i = t('4ea4');
                t('18ba');
                i(t('66fd'));
                var o = i(t('2f81'));
                e.__webpack_require_UNI_MP_PLUGIN__ = t;
                n(o.default);
            }.call(this, t('bc2e').default, t('543d').createPage));
        },
        d37e: function (e, n, t) {
            'use strict';

            var i = t('037a');
            t.n(i).a;
        }
    },
    [['cc2b', 'common/runtime', 'common/vendor']]
]);
</script>
<style>
@import './index.css';
</style>
